<template>
  <div class="home">
    <!-- <img alt="Vue logo" src="../assets/imgs/logo.png" />-->
    <!-- <HelloWorld msg="Welcome to Your Vue.js App" /> -->

    <h3>{{food}}</h3>
    <button @click="changeAppName">换数据</button>
    <button @click="setAppV">SET数据</button>
    <h3>{{appVersion}}</h3>
  </div>
</template>

<script>
// @ is an alias to /src
// import HelloWorld from '@/components/HelloWorld.vue'
import { mapState } from 'vuex'
export default {
  // name: 'Home',
  // components: {
  //   HelloWorld
  // }
  props: {
    food: {
      type: String,
      default: 'Home'
    }
  },
  computed: {
    // 方法1：
    ...mapState({
      appVersion: states => states.state.appVersion
    })
  },
  methods: {
    changeAppName() {
      this.$store.commit('SET_APPNAME', 'ddddd')
    },
    setAppV() {
      this.$store.commit('SET_APP_VERSION')
    }
  }
}
</script>
